<?php
class AdminControl extends ControlHelp
{
    private static $Contorl,$AdminRbac;
    //public  static $db;
    public function __construct()
    {                   
        parent::__construct();
        if (Session::getByKey("adminname") == "" ) 
            echo"<script>alert(\"提示:请您先登录".Session::getByKey("adminname")."\");top.location=\"adminlogin.php\";</script>"; 
    }
    public function showPages()
    {
        return parent::PageUrl();
    }
    public function logout()
    {
        Session::clear();
        echo "<script>alert(\"提示:您已成功退系统\");top.location=\"/\"</script>";
    }
    
    public function showTables()
    {
        return $this->listTables(Config::$dbSettings['dbName']);    
    }
    public function showFields($tableName)
    {
        return $this->listFields($tableName);  
    }
   //'***************************************************
   //' 表操作 表:fileditems  操作:Save,Del,List,Model
   //'***************************************************    
    public function showfileditems($whstr=array())
    {
        parent::checkRbac('Listadmins_access');
        return parent::listModel('fileditems',$whstr);
    }   
   
   //'***************************************************
   //' 表操作 表:tableitems  操作:Save,Del,List,Model
   //'***************************************************    
    public function showtableitems($whstr=array())
    {
        parent::checkRbac('Listadmins_access');
        return parent::listModel('tableitems',$whstr);
    }          
    public function deltableitems($id)
    {
        $mydb = new DataBaseObject();
        return $this->delete('tableitems',array('ID' => $id ));
    }    
   //'***************************************************
   //' 节点表操作 表:admins_node  操作:Save,Del,List,Model
   //'***************************************************    
     //新增
    public function createAdminsNode()
    {
        return parent::SaveModel("admins_node");
    }
    //修改
    public function editAdminsNode()
    {
        return parent::SaveModel("admins_node");
    }
    //删除
    public function delAminsNode($id)
    {
        return $this->delete('admins_node',array('ID' => $id ));
    }
    //列表
    public function listAdminsNode($whstr= array())
    {
        return parent::listModel('admins_node',$whstr);
    }
    //实体
    public function modleAdminsNode($id)
    {            
        return $this->selectSingle('admins_node',array('id'=>$id));
    }   
   
   
    /********************************************
     * 权限组操作 表:admins_group  操作:Save,Del,List,Model
     ********************************************/
     
    //列表
    public function listAdminsGroup($whstr= array())
    {
        return parent::listModel('admins_group',$whstr);
    }
    public function createAdminGroup()
    {        
        $groupid = parent::SaveModel("admins_group");
        parent::SaveModel_1($groupid);
    }
    public function editAdminGroup()
    {
        //parent::SaveModel("admins_access");   
        $this->delete('admins_access',array('groupid'=>Post::getByKey('id'))); 
        parent::SaveModel_1(Post::getByKey('id'));
        return parent::SaveModel("admins_group");
    }
    public function delAdminGroup($id)
    {
        return $this->delete('admins_group',array('ID' => $id ));        
    }
    public function modleAdminGroup($id)
    {    
        return $this->selectSingle('admins_group',array('id'=>$id));
    }
    
   //---fileditems---//
   //***************************************************
   // 表操作 表:fileditems  操作:Save,Del,List,Model
   //*************************************************** 
    public function createfileditems()
    {
        parent::checkRbac('Addfileditems');
        return parent::SaveModel("fileditems");
    }
    public function editfileditems()
    {
        parent::checkRbac('Editfileditems');
        return parent::SaveModel("fileditems");
    }
    public function delfileditems($id)
    {
        return $this->delete('fileditems',array('ID' => $id ));
    }
    public function listfileditems($whstr= array())
    {
        parent::checkRbac('Listfileditems');
        return parent::listModel('fileditems',$whstr,false);
    }
    public function modlefileditems($id)
    {
        parent::checkRbac('Viewfileditems');
            
        return $this->selectSingle('fileditems',array('id'=>$id));
    } 
    
   //---tableitems---//
   //***************************************************
   // 表操作 表:tableitems  操作:Save,Del,List,Model
   //*************************************************** 
    public function createtableitems()
    {
        parent::checkRbac('Addtableitems');
        return parent::SaveModel("tableitems");
    }
    public function edittableitems()
    {
        parent::checkRbac('Edittableitems');
        return parent::SaveModel("tableitems");
    }
    public function listtableitems($whstr= array())
    {
        parent::checkRbac('Listtableitems');
        return parent::listModel('tableitems',$whstr);
    }
    public function modletableitems($id)
    {
        parent::checkRbac('Viewtableitems');
            
        return $this->selectSingle('tableitems',array('id'=>$id));
    } 
    
    
   //---admins---//
   //***************************************************
   // 表操作 表:admins  操作:Save,Del,List,Model
   //*************************************************** 
    public function createadmins()
    {
        parent::checkRbac('Addadmins');
        return parent::SaveModel("admins");
    }
    public function editadmins()
    {
        parent::checkRbac('Editadmins');
        return parent::SaveModel("admins");
    }
    public function delAmins($id)
    {
        parent::checkRbac('Deladmins');
        $mydb = new DataBaseObject();
        return $this->delete('admins',array('ID' => $id ));
    }
    public function listadmins($whstr= array())
    {
        parent::checkRbac('Listadmins');
        return parent::listModel('admins',$whstr);
    }
    public function modleadmins($id)
    {
        parent::checkRbac('Viewadmins');
        return $this->selectSingle('admins',array('id'=>$id));
    } 
    
   //---admins_access---//
   //***************************************************
   // 表操作 表:admins_access  操作:Save,Del,List,Model
   //*************************************************** 
    public function createadmins_access()
    {
        parent::checkRbac('Addadmins_access');
        return parent::SaveModel("admins_access");
    }
    public function editadmins_access()
    {
        parent::checkRbac('Editadmins_access');
        return parent::SaveModel("admins_access");
    }
    public function deladmins_access($id)
    {
        parent::checkRbac('Deladmins_access');
        $mydb = new DataBaseObject();
        return $this->delete('admins_access',array('ID' => $id ));
    }
    public function listadmins_access($whstr= array())
    {
        parent::checkRbac('Listadmins_access');
        return parent::listModel('admins_access',$whstr);
    }
    public function modleadmins_access($id)
    {
        parent::checkRbac('Viewadmins_access');
            
        return $this->selectSingle('admins_access',array('id'=>$id));
    } 
    
   //---admins_group---//
   //***************************************************
   // 表操作 表:admins_group  操作:Save,Del,List,Model
   //*************************************************** 
    public function createadmins_group()
    {
        parent::checkRbac('Addadmins_group');
        return parent::SaveModel("admins_group");
    }
    public function editadmins_group()
    {
        parent::checkRbac('Editadmins_group');
        return parent::SaveModel("admins_group");
    }
    public function deladmins_group($id)
    {
        parent::checkRbac('Deladmins_group');
        $mydb = new DataBaseObject();
        return $this->delete('admins_group',array('ID' => $id ));
    }
    public function listadmins_group($whstr= array())
    {
        parent::checkRbac('Listadmins_group');
        return parent::listModel('admins_group',$whstr);
    }
    public function modleadmins_group($id)
    {
        parent::checkRbac('Viewadmins_group');
            
        return $this->selectSingle('admins_group',array('id'=>$id));
    } 
    
   //---admins_node---//
   //***************************************************
   // 表操作 表:admins_node  操作:Save,Del,List,Model
   //*************************************************** 
    public function createadmins_node()
    {
        parent::checkRbac('Addadmins_node');
        return parent::SaveModel("admins_node");
    }
    public function editadmins_node()
    {
        parent::checkRbac('Editadmins_node');
        return parent::SaveModel("admins_node");
    }
    public function deladmins_node($id)
    {
        parent::checkRbac('Deladmins_node');
        $mydb = new DataBaseObject();
        return $this->delete('admins_node',array('ID' => $id ));
    }
    public function listadmins_node($whstr= array())
    {
        parent::checkRbac('Listadmins_node');
        return parent::listModel('admins_node',$whstr);
    }
    public function modleadmins_node($id)
    {
        parent::checkRbac('Viewadmins_node');
            
        return $this->selectSingle('admins_node',array('id'=>$id));
    } 
    //---end---//
}
?>
